package cn.i7baozh.cloud.api.dto;

import lombok.Data;

import java.io.Serializable;

/**
 * @author : zlmismeno1
 * @date :   2024/12/25 11:16
 */
@Data
public class ReturnResponse<T> implements Serializable {

    private String code;

    private String message;

    private T data;

    private long timestamp;

    public ReturnResponse(){
        timestamp = System.currentTimeMillis();
    }

    public static <T> ReturnResponse<T> success(T data) {
        ReturnResponse<T> re = new ReturnResponse<T>();
        re.setCode("200");
        re.setMessage("success");
        re.setData(data);
        return re;
    }
    public static <T> ReturnResponse<T> fail(String code, String message) {
        ReturnResponse<T> re = new ReturnResponse<T>();
        re.setCode(code);
        re.setMessage(message);
        return re;
    }
}
